/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "fotos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Fotos.findAll", query = "SELECT f FROM Fotos f"),
    @NamedQuery(name = "Fotos.findByIdFoto", query = "SELECT f FROM Fotos f WHERE f.idFoto = :idFoto"),
    @NamedQuery(name = "Fotos.findByDetalhe", query = "SELECT f FROM Fotos f WHERE f.detalhe = :detalhe"),
    @NamedQuery(name = "Fotos.findByData", query = "SELECT f FROM Fotos f WHERE f.data = :data"),
    @NamedQuery(name = "Fotos.findByNivel", query = "SELECT f FROM Fotos f WHERE f.nivel = :nivel")})
public class Fotos implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idFoto")
    private Integer idFoto;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "detalhe")
    private String detalhe;
    @Basic(optional = false)
    @NotNull
    @Column(name = "nivel")
    private int nivel;
    @JoinColumn(name = "fkUsuario", referencedColumnName = "idUsuario")
    @ManyToOne(optional = false)
    private Usuario fkUsuario;
    @JoinColumn(name = "fkAlbum", referencedColumnName = "idAlbum")
    @ManyToOne(optional = false)
    private Album fkAlbum;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkFoto")
    private List<OpiniaoFoto> opiniaoFotoList;

    public Fotos() {
    }

    public Fotos(Integer idFoto) {
        this.idFoto = idFoto;
    }

    public Fotos(Integer idFoto, String detalhe, Date data, int nivel) {
        this.idFoto = idFoto;
        this.detalhe = detalhe;
        this.data = data;
        this.nivel = nivel;
    }

    public Integer getIdFoto() {
        return idFoto;
    }

    public void setIdFoto(Integer idFoto) {
        this.idFoto = idFoto;
    }

    public String getDetalhe() {
        return detalhe;
    }

    public void setDetalhe(String detalhe) {
        this.detalhe = detalhe;
    }

    public int getNivel() {
        return nivel;
    }

    public void setNivel(int nivel) {
        this.nivel = nivel;
    }

    public Usuario getFkUsuario() {
        return fkUsuario;
    }

    public void setFkUsuario(Usuario fkUsuario) {
        this.fkUsuario = fkUsuario;
    }

    public Album getFkAlbum() {
        return fkAlbum;
    }

    public void setFkAlbum(Album fkAlbum) {
        this.fkAlbum = fkAlbum;
    }

    @XmlTransient
    public List<OpiniaoFoto> getOpiniaoFotoList() {
        return opiniaoFotoList;
    }

    public void setOpiniaoFotoList(List<OpiniaoFoto> opiniaoFotoList) {
        this.opiniaoFotoList = opiniaoFotoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idFoto != null ? idFoto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fotos)) {
            return false;
        }
        Fotos other = (Fotos) object;
        if ((this.idFoto == null && other.idFoto != null) || (this.idFoto != null && !this.idFoto.equals(other.idFoto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Fotos[ idFoto=" + idFoto + " ]";
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }
    
}
